package com.prdownloader.database;

import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.data.DatabaseHelper;
import ohos.data.rdb.RdbOpenCallback;
import ohos.data.rdb.RdbStore;
import ohos.data.rdb.StoreConfig;
import ohos.hiviewdfx.HiLogLabel;

/**
 * 数据库持有Ability
 *
 * @author amitshekhar
 * @since 2017-11-17
 */
public class PersonDataAbility extends Ability {

//    private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, 0xD001100, "Demo");
//    private static final String DATABASE_NAME = "prdownloader.db";
//    private static final int DATABASE_VERSION = 1;
    /*  创建关系型数据库 */
//    private StoreConfig config = StoreConfig.newDefaultConfig(DATABASE_NAME);
//    private RdbStore rdbStore;

//    private RdbOpenCallback rdbOpenCallback = new RdbOpenCallback() {
//        @Override
//        public void onCreate(RdbStore store) {
//            store.executeSql("CREATE TABLE IF NOT EXISTS "
//                +
//                AppDbHelper.TABLE_NAME + "( "
//                +
//                DownloadModel.ID + " INTEGER PRIMARY KEY, "
//                +
//                DownloadModel.URL + " VARCHAR, "
//                +
//                DownloadModel.ETAG + " VARCHAR, "
//                +
//                DownloadModel.DIR_PATH + " VARCHAR, "
//                +
//                DownloadModel.FILE_NAME + " VARCHAR, "
//                +
//                DownloadModel.TOTAL_BYTES + " INTEGER, "
//                +
//                DownloadModel.DOWNLOADED_BYTES + " INTEGER, "
//                +
//                DownloadModel.LAST_MODIFIED_AT + " INTEGER "
//                +
//                ")");
//        }
//
//        @Override
//        public void onUpgrade(RdbStore store, int oldVersion, int newVersion) {
//        }
//    };

    @Override
    public void onStart(Intent intent) {
        super.onStart(intent);
        /* 初始化数据库连接 */
//        DatabaseHelper databaseHelper = new DatabaseHelper(this);
//        rdbStore = databaseHelper.getRdbStore(config, DATABASE_VERSION, rdbOpenCallback, null);
    }
}
